<script src="__PUBLIC__/ganged/Js/city-picker.data.js"></script>
<script src="__PUBLIC__/ganged/Js/city-picker.js"></script>
<script src="__PUBLIC__/ganged/Js/main.js"></script>
<!-- css -->
<link href="__PUBLIC__/ganged/Css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/ganged/Css/city-picker.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/uploadify/jquery.uploadify.min.js" ></script>
<link rel="stylesheet" charset="utf-8" type="text/css" href="__PUBLIC__/admin/js/uploadify/uploadify.css"> 
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/upload.js" ></script>
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/admin/js/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/admin/js/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('edit');
</script>

<style>
.bg{ background: none; border: none;}
.uploadify-button-text{ display: inline-flex; }
.uploadify-button-text button{ margin: -10px; }
.upviewer img{ height:90px; width: 120px; }
.upviewer ul{ margin:0px; padding:0px; }
.upviewer li{ margin:0px; padding:0px; position: relative; display:inline-block; width:120px; height:90px; background-position: center; background-size: contain; background-repeat: no-repeat; float: left; margin-right:10px; border:1px #ccc solid; background-color:#f0f0f0;}
.upviewer li a{ display:inline-block; position: absolute; bottom:0px; left:0px; text-align:center; width:100%; background-color:rgba(0,0,0,0.3); color:red; cursor: pointer; }
.upviewer li:hover a{ background-color:rgba(0,0,0,0.8); }
</style>
<div class="container" style="padding-top: 50px;">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <form class="form-horizontal" role="form" id="post_form" action="{:U('add')}">
                <div class="form-group">
                    <label for="category_id" class="col-sm-2 control-label">类型:<span style="color: red;">*</span></label>
                    <div class="col-sm-2">
                        <div class="control-group">
                            <select name="category_id" id="category_id" class="form-control"> 
                                <option value="0">请选择类型</option>
                                <volist name="category" id="vo">
                                    <option value="{$vo['id']}">{$vo['title_display']}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="goods_name" class="col-sm-2 control-label">商品名称:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="goods_name" id="goods_name"/>
                    </div>
                </div>

                <div class="form-group">
                     <label for="desc" class="col-sm-2 control-label">商品描述:</label>
                    <div class="col-sm-6">
                        <textarea type="text" class="form-control" id="desc" name="desc" rows="3"></textarea>
                    </div>
                </div>

                <div class="form-group">
                    <label for="price" class="col-sm-2 control-label">价格:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="price" id="price"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="stock_num" class="col-sm-2 control-label">库存:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="stock_num" id="stock_num"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="sort" class="col-sm-2 control-label">排序:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="sort" id="sort" value="100" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">状态:</label>
                    <div class="col-sm-10">
                        <label for="status1" class="control-label">
                            <input type="radio" id="status1" name="status" value="0">下架
                        </label>
                        <label for="status2" class="control-label">
                            <input type="radio" id="status2" name="status" value="1"  checked>上架
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label for="img" class="col-sm-2 control-label">图片(265x255):<span style="color: red;">*</span></label>
                    <div class="col-sm-10 js_upload_img">
                        <input type="file" class="form-control" id="img"><br /> 
                        <div name="img" class="upviewer">
                            <ul></ul>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="imgs" class="col-sm-2 control-label">组图(640x200):<span style="color: red;">*</span></label>
                    <div class="col-sm-10 js_upload_imgs">
                        <input type="file" class="form-control" id="imgs"><br /> 
                        <div name="imgs" class="upviewer">
                            <ul></ul>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                     <label for="content" class="col-sm-2 control-label">商图详情:</label>
                    <div class="col-sm-10" >
                    <textarea id="edit" name="content" id="content" type="text/plain"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" class="btn btn-primary" id="btn" lng="0" lat="0">提交</button>
                    </div>
                </div>
            </form>
        </div>
</div>
<script>
$(function(){
    $("#btn").click(function(){
            var $form = $("#post_form");
            var $data = {};
            var $form_data = $form.serializeArray();
            $.each($form_data, function(k, v){
                $data[v['name']] = v['value'];
            })
            $.post($form.attr('action'), $data, function(obj){
                alert(obj.m);
                if(obj.s){
                    if(typeof(obj.url)!= "undefined" && obj.url){
                        location.href = obj.url;
                    }
                }
            })
            return false;
        })
    });
</script>
